<!DOCTYPE html>
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
<body id="cas">
<main class="container mt-3 mb-3">
    <div layout:fragment="content" id="login">
        <span th:remove="tag" th:if="${#cas.isTrue(#cas.theme('cas.browser-storage.show-progress'))}">
            <div id="mainPanel" class="mdc-card p-4 m-auto w-lg-50">
                <h2 th:utext="#{screen.processing.title}"></h2>
                <p th:utext="#{screen.processing.text}"></p>
                <div role="progressbar" class="mdc-linear-progress mdc-linear-progress--indeterminate">
                    <div class="mdc-linear-progress__buffer">
                        <div class="mdc-linear-progress__buffer-bar"></div>
                        <div class="mdc-linear-progress__buffer-dots"></div>
                    </div>
                    <div class="mdc-linear-progress__bar mdc-linear-progress__primary-bar">
                        <span class="mdc-linear-progress__bar-inner"></span>
                    </div>
                    <div class="mdc-linear-progress__bar mdc-linear-progress__secondary-bar">
                        <span class="mdc-linear-progress__bar-inner"></span>
                    </div>
                </div>
            </div>
        </span>
        <span th:remove="tag" th:if="${'false' == #strings.defaultString(#cas.theme('cas.browser-storage.show-progress'), 'true')}">
           <style type="text/css">body {display:none;}</style>
        </span>
        <form method="post" id="fm1" style="display: none">
            <input type="hidden" name="execution" th:value="${flowExecutionKey}" />
            <input type="hidden" name="_eventId" value="continue" />
            <input type="hidden" id="browserStorage" name="browserStorage"/>
        </form>
        
        <script th:inline="javascript">
            document.addEventListener('DOMContentLoaded', () => {
                /*<![CDATA[*/
                const browserStorage = /*[[${browserStorage}]]*/ ;
                let payload;
                if (browserStorage.storageType === 'SESSION') {
                    payload = readFromSessionStorage(browserStorage);
                } else {
                    payload = readFromLocalStorage(browserStorage);
                }
                if (Object.keys(payload).length > 0) {
                    document.getElementById("browserStorage").value = JSON.stringify(payload);
                }
                document.getElementById("fm1").submit();
                /*]]>*/
            });
        </script>

        <noscript>
            <p>
                <style type="text/css">
                    #mainPanel {display:none;}
                </style>
            <div class="mdc-card p-4 m-auto w-lg-50 banner banner-danger alert alert-danger">
                <h2 th:utext="#{screen.browser.js.disabled.title}"></h2>
                <p class="intro" th:utext="#{screen.browser.js.disabled.text}"></p>
            </div>
            </p>
        </noscript>
    </div>
</main>
</body>
</html>
